#ifndef LDCOMMON_H
#define LDCOMMON_H



#include <QApplication>
#include <QDir>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <string.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


#include <errno.h>


#ifdef WIN32
#include <WinSock2.h>
#include <ws2ipdef.h>
#include <pthread.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dirent.h>
#include <sys/file.h>
#define  SOCKET   int
#define  WSAGetLastError    errorno
#define  closesocket        close
#endif
#include <QMetaType>

#include <rga/RgaUtils.h>

#define MAX_FRAME_BUFF_CNT     (4)
#define FRAME_MAX_LEN        (1920*1200*3)

typedef struct
{

    uint8_t              ucData[FRAME_MAX_LEN];

    int                  nDataLen;
    int                  nSeq;
    uint64_t             nPts;
    struct timeval       nTimeStamp;
}stVFrame;

#ifndef SAFE_DELETE
#define SAFE_DELETE(p) {if(p) {delete (p);(p)=NULL;}}
#endif


#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) {if(p) {delete[] (p);(p)=NULL;}}
#endif

    #define CLEAR(x) memset(&(x), 0, sizeof(x))

#include <sys/ioctl.h>

#include <rga/im2d.hpp>
#include <rga/im2d_type.h>
#include <rga/RgaUtils.h>
#include <rga/rga.h>

#include "dma_alloc.h"




#define FBPOOL_MAGIC "FBPL"

#define FPS_UPDATE_INTERVAL 60
#define ERR(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
#define FMT_NUM_PLANES 1
#define BUFFER_COUNT 3

#define STR_BUFF_LEN          (512)

#endif // LDCOMMON_H
